//
//  TTCustomInfoTableViewCell.m
//  TaoTuo
//
//  Created by LG on 2020/11/24.
//  Copyright © 2020 刘广. All rights reserved.
//

#import "TTCustomInfoTableViewCell.h"

@interface TTCustomInfoTableViewCell ()

@property (nonatomic, strong) CAShapeLayer *bgLayer;
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel *contentLabel;

@end

@implementation TTCustomInfoTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self setupSubviews];
        
        
    }
    
    return self;
    
}

- (void)setModel:(TTCustomInfoModel *)model
{
    self.titleLabel.text = model.title;
    self.contentLabel.text = model.content;
    
    self.contentLabel.textColor = model.contetnColor ? : UIColorHex(#333333);
    
    
    CGFloat corner = model.rectCorner == 0 ? 0 : 10;
    CGRect rect = CGRectMake(0, 0, SCREEN_WIDTH - 20, 36);
    UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:rect byRoundingCorners:model.rectCorner cornerRadii:CGSizeMake(corner, corner)];
    self.bgLayer.path = path.CGPath;
    
}

- (void)setupSubviews
{
    _bgLayer = [CAShapeLayer layer];
    _bgLayer.fillColor = UIColor.whiteColor.CGColor;
    [self.layer addSublayer:_bgLayer];
    
    _titleLabel = [UILabel labelWithTitle:@"" color:UIColorHex(#999999) fontSize:14];
    [self.contentView addSubview:_titleLabel];
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(12);
        make.centerY.equalTo(self);
    }];
    
    _contentLabel = [UILabel labelWithTitle:@"" color:UIColorHex(#333333) fontSize:14];
    [self.contentView addSubview:_contentLabel];
    [_contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(125);
        make.centerY.equalTo(self);
    }];
    
    
}


@end
